package com.mobile.struts.action.grid;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.mobile.business.grid.IGridTableBusiness;
import com.mobile.model.GridTable;
import com.mobile.struts.action.BaseDispatchAction;
import com.mobile.tools.JsonHelp;

public class DynamicGridAction extends BaseDispatchAction {
	/*private ITestGridTableBusiness businessClass=(ITestGridTableBusiness)getWac()
										.getBean(ITestGridTableBusiness.BEAN_ID);*/
	private IGridTableBusiness getBusinessBean(){
		return (IGridTableBusiness)getWac()
		.getBean(IGridTableBusiness.BEAN_ID);
	}
	
	protected JsonHelp<GridTable> jsonHelp=new JsonHelp<GridTable>();
	
	public ActionForward show(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String uniqueCode = request.getParameter("uniqueCode");
		//gt为从grid_table读取的表格数据
		GridTable gt=getBusinessBean().getGridTable(uniqueCode);
		//保存url基本参数的js对象
		String urlBaseParam = request.getParameter("urlBaseParam");
		
		JsonHelp<GridTable> jh=new JsonHelp<GridTable>();
		String obj = jh.getJson(gt);
		
		String jsSrc = gt.getJsSrc();
		if(jsSrc!=null&&jsSrc.length()>0){
			request.setAttribute("jsSrc", gt.getJsSrc());
		}
		
		request.setAttribute("title", gt.getName());
		request.setAttribute("obj", obj);
		request.setAttribute("uniqueCode", uniqueCode);
		request.setAttribute("urlBaseParam", urlBaseParam);
		return mapping.findForward("dynamicGrid");
	}
}
